package com.wxapp.market.service.controller.client;

import com.wxapp.common.constant.base.IBaseController;
import com.wxapp.common.constant.pojo.vm.ResultVm;
import com.wxapp.common.constant.pojo.vo.UserVo;
import com.wxapp.common.core.annotation.User;
import com.wxapp.market.api.pojo.vm.coupon.PCouponListVm;
import com.wxapp.market.service.service.CouponService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lgl
 * @Description
 * @Datetime 2023/11/23 15:21
 * @Modified By
 */
@RestController
@Tag(name = "优惠券管理")
@RequestMapping("client/coupon")
@RequiredArgsConstructor
public class CouponClientController extends IBaseController {
    private final CouponService couponService;

    @PutMapping("/receive")
    @Operation(summary ="领取优惠券列表")
    public ResultVm<String> receive(@Schema(hidden = true) @User UserVo userVo, @RequestBody List<String> couponId) {
        return couponService.receive(userVo, couponId);
    }

    @GetMapping("/getList")
    @Operation(summary ="获取优惠券列表")
    public ResultVm<List<PCouponListVm>> getList(@User(defaulted = false) UserVo userVo, @RequestParam(value = "productId", required = false) String productId) {
        return couponService.getList(userVo, productId);
    }

    @GetMapping("getCouponCount")
    @Operation(summary ="获取优惠券数量")
    public ResultVm<Integer> getCouponCount(@RequestParam("userId") String userId) {
        return couponService.getCouponCount(userId);
    }
}
